<template>
  <BaseQuery>
    <BaseQueryRight :span="24">
      <el-form :model="form" :inline="true" :size="formSize">
        <el-form-item label="客户姓名:">
          <el-input v-model="form.customerName" clearable placeholder="请输入客户姓名" />
        </el-form-item>
        <el-form-item label="客户电话:">
          <el-input v-model="form.customerMobile" clearable placeholder="请输入客户姓名" />
        </el-form-item>
        <el-form-item label="日期:">
          <el-date-picker v-model="date" type="daterange" range-separator="至" start-placeholder="开始日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd" end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="search">查询</el-button>
        </el-form-item>
      </el-form>
    </BaseQueryRight>
  </BaseQuery>
</template>

<script>
export default {
  name: "QueryForm",
  props: {
    value: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      form: {},
      date: [],
      formSize: "small",
    };
  },
  watch: {
    value: {
      handler(val) {
        this.form = val;
      },
      deep: true,
      immediate: true,
    },
    form: {
      handler(val) {
        this.$emit("input", val);
      },
    },
    date: {
      handler(val) {
        if (!val) {
          this.form.startDate = this.form.endDate = "";
          return;
        }
        this.form.startDate = val[0];
        this.form.endDate = val[1];
      },
      deep: true,
    },
  },
  methods: {
    search() {
      this.$parent.page.page = 1;
      this.$emit("search");
    },
  },
};
</script>
